<template>
    <div id="app">
        <button type="warning" @click="sub">-</button>
        <span>{{num}}</span>
        <button type="warning" @click="add">+</button>
        <el-button round>圆角按钮</el-button>
    </div>
</template>

<script>
    export default {
        name: "计数器",
        el:"#app",
        data(){
            return{
            num:1
        }},
        methods:{
            add:function () {
                // console.log('add')
                if(this.num<10){
                    this.num++;}
                else {
                    alert("抱歉，已经是最大值了哦")
                }
            },
            sub:function () {
                // console.log('sub')
                if(this.num>0){
                    this.num--;}
                else {
                    alert("不能为负值哦")
                }
            }
        },
    }
</script>

<style scoped>

</style>
